#include  "developerEmployee.h"
#include  "memoryManager.h"

DeveloperEmployee::DeveloperEmployee( const char* desc, const char* proj) 
    : Employee( desc), project( copyStr( proj)) 
{ 
}

DeveloperEmployee::DeveloperEmployee( const DeveloperEmployee& employee)
    : Employee( ), project( copyStr( employee.getProject( )))
{
    this->setID( employee.getID( ));
    this->setDescription( employee.getDescription( ));
}

void DeveloperEmployee::setProject( const char* proj)
{
    char* tmp = this->copyStr( proj);
    delete[] this->project;
    this->project = tmp;
}

const char* const DeveloperEmployee::getProject( ) const
{
    return this->project;
}

std::ostream& DeveloperEmployee::print( std::ostream& os) const
{
    return ( os << "Developer ID = "<< this->getID( )
                << ", project = " << this->getProject( ) 
                << std::endl);
}

DeveloperEmployee* DeveloperEmployee::clone( ) const
{
    DeveloperEmployee *employee = new DeveloperEmployee( *this);
    return employee;
}

DeveloperEmployee& DeveloperEmployee::operator=( const DeveloperEmployee& employee)
{
    this->setDescription( employee.getDescription( ));
    this->setProject( employee.getProject( ));
    this->setID( employee.getID( ));
    return *this;
}

DeveloperEmployee::~DeveloperEmployee( )
{
    delete[] project;
}

void* DeveloperEmployee::operator new( size_t size)
{
    MemoryManager::getInstance( )->allocateForDeveloper( size);
    return ::operator new( size);
}

void DeveloperEmployee::operator delete( void* p, size_t size)
{
    MemoryManager::getInstance( )->releaseForDeveloper( size);
    ::operator delete( ( DeveloperEmployee*)p);
}
